<template>
  <div id="app">
    <ul class="body">
      <li v-for="(item, index) in list" :key="index">
        <div :is="item.com" v-if="activeIndex == index"></div>
      </li>
    </ul>
    <footer>
      <ol class="foot">
        <li
          v-for="(item, index) in list"
          :key="index"
          @click="activeIndex = index"
          :class="{ on: activeIndex == index }"
        >
          {{ item.title }}
        </li>
      </ol>
    </footer>
  </div>
</template>

<script>
import Home from "./components/Home.vue";
import Buy from "./components/Buy.vue";
import Serve from "./components/Serve.vue";
import My from "./components/My.vue";

export default {
  name: "App",
  components: {
    Home,
    Buy,
    Serve,
    My,
  },
  data() {
    return {
      list: [
        {
          com: "Home",
          title: "首页",
        },
        {
          com: "Buy",
          title: "购买",
        },
        {
          com: "Serve",
          title: "服务",
        },
        {
          com: "My",
          title: "我的",
        },
      ],
      activeIndex: 0,
    };
  },
};
</script>

<style>
*{
  margin: 0;
  padding: 0;
  list-style: none;
  box-sizing: border-box;
}
#app{
  width: 100vw;
  height: 100vh;
  display: flex;
  flex-direction: column;
}
.body{
  flex: 1;
}
.foot{
  width: 100%;
  height: 50px;
  display: flex;
  justify-content: space-around;

}
.on{
  color: #000;
  font-weight: 1000;
}
</style>
